﻿<%@ Page Title="Manage Web Resources" Theme="WebAdmin" Language="C#" MasterPageFile="~/WebAdmin/WebAdmin.master" AutoEventWireup="true" CodeFile="ManageWebResources.aspx.cs" Inherits="WebAdmin_ManageWebResources" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="submenu">
        <div align="right" class="smallgraytext" style="padding: 9px;">
            <a href="#" onclick="OpenEditModuleDialog(0,'');">Create New Web Resource</a>
        </div>
    </div>
<div id="contenttext">
        <div style="padding: 0px 10px 10px 10px">
            <div style="text-align: left;">
                <h3 style="margin:0px;">
                    Web Resources List</h3>
                    <div id="message1" style="display:none;">Here's an info message.</div>
<asp:GridView ID="GVWebResources" Width="100%" AutoGenerateColumns="False" runat="server"
                                CssClass="GridViewStyle" AllowSorting="true" GridLines="None">
                                <Columns>
                                    <asp:BoundField DataField="Name" HeaderText="Name" />
                                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Manage">
                                        <ItemTemplate>
                                            <a href="ManageResources.aspx?Id=<%#Eval("Id") %>" >Manage</a>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Edit">
                                        <ItemTemplate>
                                            <a href="#" onclick="OpenEditModuleDialog(<%#Eval("Id") %>,'<%#Eval("Name") %>');"><img alt="Edit resource" title="Edit resource" src="../App_Themes/WebAdmin/buttons/page_white_edit.png"  width="24" height="24" ></img></a></ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Delete">
                                        <ItemTemplate>
                                            <a onclick="if(confirm('Are you sure want to delete this resource?')){DeleteResource(<%#Eval("Id") %>);}" href="#"><img alt="Delete resource" title="Delete resource" src="../App_Themes/WebAdmin/buttons/page_delete.png" width="24" height="24"  ></img></a></ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <RowStyle  CssClass="RowStyle" />
                                <EmptyDataRowStyle CssClass="EmptyRowStyle" />
                                <PagerStyle CssClass="PagerStyle" />
                                <SelectedRowStyle CssClass="SelectedRowStyle" />
                                <HeaderStyle CssClass="HeaderStyle" />
                                <EditRowStyle CssClass="EditRowStyle" />
                                <AlternatingRowStyle CssClass="AltRowStyle" />
                                <EmptyDataTemplate>No Web Resources</EmptyDataTemplate>
                            </asp:GridView>
            </div>
        </div>
    </div>
    <script language="javascript" type="text/javascript">
        function OpenEditModuleDialog(id, Name) {
            document.getElementById("hidWebResourceId").value = id;
            document.getElementById("txtWebResourceName").value = Name;
           
            $("#dialogEditWebResource").dialog({
                modal: true,
                title: 'Web Resource',
                width: 380,
                height: 180,
                buttons: {
                    "Save": function () {
                        document.getElementById("hidWebResourceCommand").value = "Save";
                        document.getElementById("EditWebResource").submit();
                    },
                    Close: function () {
                        $(this).dialog('close');
                    }
                }
            });
        }
        function DeleteResource(id) {
            document.getElementById("hidWebResourceId").value = id;
            document.getElementById("hidWebResourceCommand").value = "Delete";
            document.getElementById("EditWebResource").submit();
        }
    </script>
</asp:Content>

